package com.group.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.group.pojo.Common;
import com.group.service.CommonService;

/**
 * 公共处理
 * @author caoyanan
 * @time 2017年10月10日下午6:57:48
 */
@Controller
@RequestMapping("/common")
public class CommonController {
	
	@Autowired
	private CommonService commonService;

	@RequestMapping("/getClientIp.action")
	@ResponseBody
	public String getClientIp(HttpServletRequest request) {
		if (request.getHeader("x-forwarded-for") == null) { 
	        return request.getRemoteAddr(); 
	    } 
	    return request.getHeader("x-forwarded-for");
	}
	
	@RequestMapping("/getColumnNameByIdAndTbName.action")
	@ResponseBody
	public String getColumnNameByIdAndTbName(Common common) {
		String resultName = commonService.getColumnNameByIdAndTbName(common);
		return resultName;
	}
}
